package com.tanhua.server.controller;

import com.tanhua.domain.vo.VisitorVo;
import com.tanhua.server.service.VisitorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/movements")
public class VisitorsController {

    //注入VisitorsService
    @Autowired
    private VisitorsService visitorsService;

    /**
     * 谁看过我
     *
     * @return
     */
    @GetMapping("visitors")
    public ResponseEntity queryVisitors() {
        //a.调用service  返回VisitorsVo对象
        List<VisitorVo> visitorVoList = visitorsService.queryVisitors();
        //转成数组
        Object[] objects = visitorVoList.toArray();
        //b.返回状态码
        return ResponseEntity.ok(objects);

    }

}
